<template>
  <el-row v-loading="loading">
    <p>通道状态：<span class="fz12" :class="chennel_status === -200 ? 'err' : chennel_status === 200 ? 'succ' : 'tip'">{{ chennel_status === -200 ? '审核未通过' : chennel_status === 0 ? '未提交' : chennel_status ===  100 ? '待审核' : chennel_status === 200 ? '审核通过': '无' }}</span></p>
    <p v-if="chennel_status === -200">错误信息：<span class="fz12 err">{{ error_info }}</span></p>
    <p>微信APPID：{{ wx.app_id }}</p>
    <p>微信商户号：{{ wx.wx_commer_id }}</p>
    <p>商家结算周期：{{ wx.balance_type }}</p>
    <p>通道类型：{{ wx.channel_type === 0 ? '普通' : wx.channel_type === 1 ? '绿洲计划' : wx.channel_type === 2 ? '公益类': '无' }}</p>
    <p>当前执行费率：{{ wx.rate }}%</p>
    <p v-if="wx.channel_type !== 2">到期时间：{{ wx.expire_time }}</p>
    <p v-if="wx.expire_time">到期执行费率：{{ wx.expire_rate }}%</p>
  </el-row>
</template>

<script>
import { merchantChannelWxQuery } from '@/api/shop'

export default {
  data() {
    return {
      loading: true,
      chennel_status: '',
      error_info: '',
      wx: {
        app_id: '',
        wx_commer_id: '',
        balance_type: '',
        rate: '',
        expire_time: '',
        expire_rate: '',
        channel_type: ''
      }
    }
  },
  methods: {
    handleDocumentInit() {
      merchantChannelWxQuery(this.$route.query.merchant_num).then(res => {
        if (res.data.errorCode === 0) {
          this.loading = false
          this.wx.wx_commer_id = res.data.result.wx_commer_id
          this.wx.app_id = res.data.result.app_id
          this.wx.balance_type = res.data.result.balance_type
          this.wx.channel_type = res.data.result.channel_type
          this.wx.expire_rate = Number(res.data.result.expire_rate)
          this.wx.expire_time = res.data.result.expire_time
          this.wx.rate = Number(res.data.result.rate)
          this.chennel_status = res.data.result.channel_status
          this.error_info = res.data.result.error_info
        } else {
          this.$message.error(res.data.errorMsg)
        }
      })
    }
  },
  created() {
    this.handleDocumentInit()
  }
}
</script>
